/**
 * Created by JamesZhang on 2017/5/21.
 */
import React from "react";
import {withRouter} from "react-router";




class Demo extends React.Component{
    constructor(props){
        super(props);
    }
    render(){
        return (
            <div>
                <p>
                    Hello world
                </p>

            </div>
        )
    }
}


class List extends React.Component{
    constructor(props, context){
        super(props, context);
        this.state = {
            hello: 'Hello James!!!',
            message: "按需加载生效了!!!"
        };

    }

    hello() => {
        console.log('helloworld');
    }
    render(){

        // 若没有包裹withRouter, 则返回的是一个空对象
        console.log('this.props', this.props);

        return (
            <div>
                <h1>{this.state.hello}</h1>
                <div>
                    <h1>{this.state.message}</h1>
                </div>
            </div>
        )
    }
}
/*** 使用懒加载时, 就无法使用this.props等属性了.
 * 此时, 只需要加上withRouter包裹下, 就可以解决此问题!
 * ***/
export default withRouter(List);
// export default List;